作者:.NET开发
项目:System.Activitie
public sealed class ReadInt : NativeActivity<int>
{
[RequiredArgument]
public InArgument<string> BookmarkName { get; set; }
protected override void Execute(NativeActivityContext context)
{
string name = BookmarkName.Get(context);
if (string.IsNullOrEmpty(name))
{
throw new ArgumentException("BookmarkName cannot be an Empty string.",
"BookmarkName");
}
context.CreateBookmark(name, new BookmarkCallback(OnReadComplete));
}
// NativeActivity derived activities that do asynchronous operations by calling
// one of the CreateBookmark overloads defined on System.Activities.NativeActivityContext
// must override the CanInduceIdle property and return true.
protected override bool CanInduceIdle
{
get { return true; }
}
void OnReadComplete(NativeActivityContext context, Bookmark bookmark, object state)
{
this.Result.Set(context, Convert.ToInt32(state));
}
}